using System;
using System.Collections.Generic;
using System.Text;
using WozLib.UI.Ink;

namespace WozLib.WozObjects
{
  public class ScreenServerObject : SketchPadServerObject
  {
    public ScreenServerObject()
    {
    }

    public ScreenServerObject(long serverID)
      : base(serverID)
    {
    }

    public override IServerObject GetIServerObject()
    {
      // we'll first try to let our base pull it out of the registry or create one 
      IServerObject iServerObject = base.GetIServerObject();

      // if our base didn't couldn't find the IServerObject
      // or if it's of the wrong type, we'll try to make our own
      if (iServerObject == null || !(iServerObject is WozScreen))
      {
        iServerObject = WozScreen.FromScreenServerObject(this);

        ServerObjectRegistry.RegisterObjectWithExisitingId(iServerObject);

        // !!! the code below is wrong - it will cause the newly created iServerObject not to
        // actually be created - replaced with above code
        // don't know where else this is broken

        // if we do not the IWozObject we just created is not registered, register it
        //if (iServerObject != null && !ServerObjectRegistry.ContainsObject(iServerObject.ServerID))
        //{
        //  ServerObjectRegistry.RegisterObjectWithExisitingId(iServerObject);
        //}
      }

      return iServerObject;
    }
  }
}
